<template>
  <div class="modelCalibration">
    <MetaSearchForm @on-search="tableSearch">
      <el-form :model="searchData" class="modelOptimization_searchFrom">
        <el-form-item
          label="设备"
          class="modelOptimization_searchFromItem"
          label-width="80px"
        >
          <el-select
            v-model="searchData.equipmentId"
            placeholder="请选择设备"
            filterable
            clearable
          >
            <el-option
              v-for="item in equipmentList"
              :key="item.id"
              :label="item.equipmentName"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="模型校准时间"
          class="modelOptimization_searchFromItem"
          label-width="150px"
        >
          <el-date-picker
            v-model="searchData.dateBetween"
            type="daterange"
            range-separator="-"
            value-format="yyyy-MM-dd"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
    </MetaSearchForm>
    <MetaPageTable
      ref="modelCalibrationTable"
      class="modelCalibration_table"
      table-title="模型校准列表"
      :is-auto-req="true"
      :req-url="reqUrl"
      :req-data="searchDataForTable"
      req-method="post"
      :display-item="displayItem"
      @btnClick="tableBtnClick"
      :line-btn-group="lineBtnGroup"
      @lineBtnClick="tableInlineBtnClick"
    />
    <!-- 模型评价窗口 -->
    <el-dialog :visible.sync="commentDialogFlag" width="80%" @opened="commentDialogOpen">
      <div>
        <!-- paramsList从后台返回 -->
        <el-tabs @tab-click="handleClick" v-model="activeName" type="card">
          <el-tab-pane
            v-for="(item, index) in paramsBackList"
            :key="index"
            :label="item.key"
            class="commentContent"
          >
            <div class="commentContentTop">
              <div class="commentContentTopItem">模型-均值：<span style="color:#409eff">{{item.saverage}}</span></div>
              <div class="commentContentTopItem">输入-均值：<span style="color:#409eff">{{item.taverage}}</span></div>
              <div class="commentContentTopItem">均差：<span style="color:#409eff">{{item.value[0].modelvalue[0]}}</span></div> 
              <div class="commentContentTopItem">均比：<span style="color:#409eff">{{item.value[1].modelvalue[0]}}</span></div> 
              <div class="commentContentTopItem" style="width:300px">拟合系数：<span style="color:#409eff">{{item.value[2].modelvalue[0]}} , {{item.value[2].modelvalue[1]}}</span></div> 
            </div>
            <div class="commentContentMiddle">
              <div
                v-for="(valueItem, valueIndex) in item.value"
                :key="valueIndex"
                class="commentContentItem"
              >
                  <el-radio
                    v-model="item.modelChoose"
                    :label="index + valueIndex"
                    style="display: flex"
                    @change="dataChoose(index, valueIndex, valueItem)"
                  >
                    <div class="everyComment" v-html="valueItem.evaluate"></div
                  ></el-radio>
              </div>
              <div
                  :id="'echart' + index"
                  style="max-width: 1000px; height: 280px;margin-top:30px"
                ></div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
      <div slot="footer">
        <el-button @click="cancelData">取 消</el-button>
        <el-button type="primary" @click="sendDataTo()">保 存</el-button>
      </div>
    </el-dialog>
    <!-- 模型查看窗口 -->
    <el-dialog title="指标模型" :visible.sync="showDialogFlag" width="80%" center modal>
      <div>
        <MetaPageTable
          ref="indexModelTable"
          class="modelComment_table"
          table-title="指标模型列表 "
          :is-auto-req="true"
          :req-url="modelReqUrl"
          :req-data="indexModelSearch"
          req-method="post"
          :display-item="modelDisplayItem"
          :line-btn-group="modelLineBtnGroup"
          @lineBtnClick="modelInLineBtnClick"
        />
      </div>
    </el-dialog>
    <!-- 重命名窗口 -->
    <el-dialog
      title="指标模型重命名"
      :visible.sync="renameDialogFlag"
      width="60%"
      :before-close="renameCancel"
      center
      modal
    >
      <div>
        <el-form
          :model="renameForm"
          label-width="150px"
          :rules="renameFormRules"
          ref="renameForm"
        >
          <el-form-item label=" 模型名称" style="width: 80%">
            <div>{{ renameForm.modelName }}</div>
          </el-form-item>
          <el-form-item label=" 模型重命名" style="width: 80%" prop="rename">
            <el-input v-model="renameForm.rename"></el-input>
          </el-form-item>
        </el-form>
      </div>

      <div slot="footer">
        <el-button @click="renameCancel">取 消</el-button>
        <el-button type="primary" @click="renameFinish">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 模型详情曲线窗口 -->
    <el-dialog :visible.sync="historyDialogFlag" width="50%">
      <div class="evaluateShowTitle">参数模型：</div>
      <div class="evaluateShow" style="color: #66b1ff">{{ modelName }}</div>
      <div class="evaluateShowTitle">参数评价：</div>
      <div class="evaluateShow" v-html="evaluate" style="color: #66b1ff"></div>
      <div class="evaluateShowTitle">
        <div id="myechart" style="height: 280px; margin-top: 30px"></div>
      </div>

      <div slot="footer">
        <el-button @click="historyDialogFlag = false">取 消</el-button>
        <el-button type="primary" @click="historyDialogFlag = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import MetaPageTable from "../components/MetaPageTable";
import MetaSearchForm from "../components/MetaSearchForm";
import deepClone from "../utils/deepClone";
import utils from "../utils/utils";
import { validateLetterNumberWord } from "../utils/validate";

export default {
  name: "modelCalibration",
  components: {
    MetaPageTable,
    MetaSearchForm,
  },
  data() {
    let checkName = (rule, value, callback) => {
      if (!value) {
        callback(new Error("必填项不可为空"));
      } else {
        if (value.length > 50) {
          callback(new Error("内容录入过长"));
        } else if (!validateLetterNumberWord(value)) {
          callback(new Error("请准确输入名称"));
        } else {
          return callback();
        }
      }
    };
    return {
      exportDialogFlag: false,
      optimizeDialogVisible: false,
      commentDialogFlag: false,
      showDialogFlag: false,
      renameDialogFlag: false,
      historyDialogFlag: false,
      searchData: {
        username: localStorage.getItem("username"),
        type: "calibration",
      },
      searchDataForTable: {
        username: localStorage.getItem("username"),
        modelTempId: "",
        equipmentId: "",
        type: "calibration",
      },
      searchDataForDataTable: {
        equipmentId: "",
        time: "",
      },
      reqUrl: process.env.PROGOO_GATE_WATER + "model/getModelResult",
      dataReqUrl: process.env.PROGOO_GATE_WATER + "admin/getDataList",
      modelReqUrl: process.env.PROGOO_GATE_WATER + "model/getList",
      indexModelSearch: {
        modelTempId: "",
        username: localStorage.getItem("username"),
      },
      displayItem: [
        {
          label: "设备",
          prop: "equipmentName",
        },
        {
          label: "模型构建时间",
          prop: "createDate",
        },
        {
          label: "构建状态",
          prop: "modelStatus",
          type: "if",
          format: {
            "00": "构建中",
            "01": "完成",
            "02": "构建失败",
          },
          color: {
            "00": "orange",
            "01": "LimeGreen",
            "02": "red",
          },
        },
        {
          label: "构建完成时间",
          prop: "completeDate",
        },
        {
          label: "备注",
          prop: "remark",
        },
      ],
      dataDisplayItem: [
        {
          label: "录入时间",
          prop: "pickTime",
          width: 200,
        },
      ],
      modelDisplayItem: [
        {
          label: "设备",
          prop: "equipmentName",
          width: "180",
        },
        {
          label: "参数",
          prop: "paramKey",
          type: "enum",
          enums: [],
          width: "130",
        },
        {
          label: "模型名称",
          prop: "modelName",
        },
        {
          label: "别名",
          prop: "modelNickname",
          width: "200",
        },

        {
          label: "优化完成时间",
          prop: "completeDate",
          width: "200",
        },
        {
          label: "备注",
          prop: "remark",
          width: "200",
        },
      ],
      
      lineBtnGroup: [
        {
          id: "choose",
          title: "选择指标",
          hideCheck: this.chooseBtnHidecheck,
        },
        {
          id: "show",
          title: "模型指标",
          hideCheck: this.showBtnHidecheck,
        },
        {
          id: "delete",
          title: "删除",
        },
      ],
      modelLineBtnGroup: [
        {
          id: "showDetail",
          title: "查看模型",
        },
        {
          id: "rename",
          title: "重命名",
        },
        {
          id: "modelDelete",
          title: "删除",
        },
      ],
      itemExportData: {
        dateBetween: [],
      },
      renameForm: { modelName: "", rename: "" },
      renameFormRules: {
        rename: [
          {
            required: true,
            validator: checkName,
            trigger: "blur",
          },
        ],
      },
      rolesList: [],
      companyList: [],
      equipmentList: [],
      paramsList: [],
      paramConfigureList: [],
      splitDisplayItem: {
        sign: ",",
        label: "modelName",
        prop: "modelKey",
        value: "modelValue",
      },
      optimizeForm: {
        equipmentId: "",
        paramKeyList: [],
        dateBetween: "",
        selectId: [],
        type: "",
        username: localStorage.getItem("username"),
        remark: "",
      },
      optimizeForm_rules: {
        equipmentId: [{ required: true, message: "请选择设备", trigger: "blur" }],
        paramKeyList: [
          {
            required: true,
            message: "请选择参数",
            type: "array",
            min: 1,
            trigger: "blur",
          },
        ],
        dateBetween: [{ required: true, message: "请选择时间范围", trigger: "blur" }],
        type: [{ required: true, message: "请选择构建类型", trigger: "blur" }],
        remark: [{ required: true, message: "请填写备注", trigger: "blur" }],
      },
      selectList: [],
      modelCommentList: [],
      paramsBackList: [],
      paramsCommentList: [],
      //三选一模型列表
      valueList: [],
      //三选一模型后需要传至后端的优化数组
      sendModelList: [],
      activeName: 0,
      //图表横轴
      chartXais: [],
      chartXais_show: [],
      //反演值结果
      inversionvalue: "",
      //真值结果
      trueValue: "",
      evaluate: "",
      dataEntryTableData: {},
      modelName: "",
      page:1
    };
  },
  mounted() {
    this.searchModelFromAlgo();
    this.getEquipment();
    this.getParams();
  },
  methods: {
    searchModelFromAlgo() {
      if (this.$route.params.modelTempId) {
        this.searchDataForTable.modelTempId = this.$route.params.modelTempId;
        this.searchDataForTable.equipmentId = this.$route.params.equipmentId;
        this.$nextTick(() => {
          this.$refs.modelCalibrationTable.formDataInit(true);
        });
      }
    },
    tableBtnClick(item) {
      if (item.button === "optimize") {
        this.searchDataForDataTable.time = ["", ""];
        this.searchDataForDataTable.equipmentId = "";
        this.selectList = [];
        this.dataEntryTableData = {};
        this.optimizeDialogVisible = true;
      }
    },
    tableInlineBtnClick(item) {
      if (item.button === "show") {
        this.showDialogFlag = true;
        this.indexModelSearch.modelTempId = item.rows.id;
        this.$nextTick(() => {
          this.$refs.indexModelTable.formDataInit(true);
        });
      } else if (item.button === "choose") {
        this.commentDialogFlag = true;
        this.modelCommentList = item.rows;
        console.log(this.modelCommentList)
        this.paramsBackList = JSON.parse(item.rows.modelText).result;
        //新增默认选择
      } else if (item.button === "delete") {
        this.$confirm("确认删除当前模型？", "确认删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.$fetch({
            url: process.env.PROGOO_GATE_WATER + "model/remove",
            method: "delete",
            data: {
              id: item.rows.id,
            },
          }).then((res) => {
            if (res.data.code === 200) {
              if (res.data.message == "成功") {
                this.$message({
                  type: "success",
                  message: "操作成功!",
                });
                this.$nextTick(() => {
                  this.$refs.modelCalibrationTable.formDataInit(true);
                });
              } else if (res.data.message == "模型占用") {
                this.$confirm(
                  "“" +
                    res.data.result[0] +
                    "”" +
                    "模型被" +
                    "“" +
                    res.data.result[1] +
                    "”" +
                    "算法占用，请解除后删除!",
                  "模型被占用",
                  {
                    confirmButtonText: "跳转至算法管理",
                    cancelButtonText: "取消",
                    type: "warning",
                  }
                )
                  .then(() => {
                    this.$router.push({
                      path: "/algorithmManagement",
                      query: {
                        searchAlgo: res.data.result[1],
                      },
                    });
                  })
                  .catch(() => {});
              }
            } else {
              this.$notify.error({
                title: "错误",
                message: res.data.message,
              });
            }
          });
        });
      }
    },
    modelInLineBtnClick(item) {
      if (item.button === "showDetail") {
        //查看模型
        this.historyDialogFlag = true;
        this.chartXais_show = []
        this.modelName = item.rows.modelName;
        this.evaluate = item.rows.evaluate;
        this.$nextTick(() => {
          this.getCharts(JSON.parse(item.rows.modelView));
        });
        console.log(JSON.parse(item.rows.modelView))
      } else if (item.button === "rename") {
        //重命名
        this.renameDialogFlag = true;
        this.renameId = item.rows.id;
        this.renameForm.modelName = item.rows.modelName;
      } else if (item.button === "modelDelete") {
        this.$confirm("确认删除当前模型？", "确认删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.$fetch({
              url: process.env.PROGOO_GATE_WATER + "evaluation/remove",
              method: "delete",
              data: {
                id: item.rows.id,
              },
            }).then((res) => {
              if (res.data.code === 200) {
                if (res.data.message == "成功") {
                  this.$notify.success({
                    title: "成功",
                    message: "模型删除成功",
                  });
                  this.$nextTick(() => {
                    this.$refs.indexModelTable.formDataInit(true);
                  });
                } else if (res.data.message == "模型占用") {
                  this.$confirm(
                    "当前模型被“" + res.data.result + "”算法占用",
                    "模型被占用",
                    {
                      confirmButtonText: "跳转至算法管理",
                      cancelButtonText: "取消",
                      type: "warning",
                    }
                  )
                    .then(() => {
                      this.$router.push({
                        path: "/algorithmManagement",
                        query: {
                          searchAlgo: res.data.result,
                        },
                      });
                    })
                    .catch(() => {});
                }
              } else {
                this.$notify.error({
                  title: "删除失败",
                  message: res.data.result,
                });
              }
            });
          })
          .catch(() => {});
      }
    },
    initTableData(page, reflash) {
      let params = {};
      params = this.searchDataForDataTable;
      params.page = page;
      params.limit = 10;
      params.sortType = "";
      params.sortOrderBy = "";
      this.$fetch({
        url: process.env.PROGOO_GATE_WATER + "admin/dataList",
        method: "post",
        data: params,
      }).then((res) => {
        if (res.data.code === 200) {
          this.dataEntryTableData = {};
          this.dataEntryTableData.page = page;
          this.dataEntryTableData.totalElements = res.data.result.totalElements;
          this.dataEntryTableData.content = res.data.result.content;
          for (let i in this.dataEntryTableData.content) {
            this.dataEntryTableData.content[i].tempParamJson = JSON.parse(
              this.dataEntryTableData.content[i].paramJson
            );
            for (let key in this.dataEntryTableData.content[i].tempParamJson) {
              this.dataEntryTableData.content[i][key] = this.dataEntryTableData.content[
                i
              ].tempParamJson[key];
            }
          }
          this.$nextTick(() => {
            this.$refs.dataEntryTable.formDataInit(reflash, this.dataEntryTableData);
          });
        } else {
          this.$notify.error({
            title: "错误",
            message: res.data.message,
          });
        }
      });
    },
    exportDialogSubmit() {
      let params = {};
      params.datestart =
        this.searchData.dateBetween.length > 0
          ? this.searchData.dateBetween[0] + " 00:00:00"
          : "";
      params.dateend =
        this.searchData.dateBetween.length > 0
          ? this.searchData.dateBetween[1] + " 23:59:59"
          : "";
      this.$fetch({
        url: process.env.PROGOO_GATE_WATER + "admin/edit",
        method: "post",
        data: params,
      }).then((res) => {
        if (res.data.code === 200) {
          this.dialogClose();
          this.$notify({
            title: "成功",
            message: "操作成功",
            type: "success",
          });
        } else {
          this.$notify.error({
            title: "错误",
            message: res.data.message,
          });
        }
      });
    },
    pageChange(e) {
      this.initTableData(e, false);
    },
    chooseBtnHidecheck(rowData, item) {
      if (rowData.displayType === "0" && rowData.modelStatus == "01") {
        //未选择指标
        return true;
      }
      return false;
    },
    showBtnHidecheck(rowData, item) {
      if (rowData.displayType === "1") {
        //已选择指标
        return true;
      }
      return false;
    },
    renameFinish() {
      //模型重命名方法
      this.$refs["renameForm"].validate((valid) => {
        if (valid) {
          this.$fetch({
            url: process.env.PROGOO_GATE_WATER + "admin/model/edit",
            method: "post",
            data: {
              modelNickname: this.renameForm.rename,
              id: this.renameId,
            },
          }).then((res) => {
            if (res.data.code === 200) {
              this.renameDialogFlag = false;
              this.$notify.success({
                title: "成功",
                message: "指标模型重命名成功",
              });
              this.renameForm.rename = "";
              this.$nextTick(() => {
                this.$refs.indexModelTable.formDataInit(true);
              });
            }
          });
        }
      });
    },
    renameCancel() {
      this.renameDialogFlag = false;
      this.renameForm.rename = "";
    },
    handleClick(tab, event) {
      this.$nextTick(() => {
        this.getAllCharts(tab.index);
      })
    },
    dataChoose(index, valueIndex, valueItem) {
      console.log(index)
      console.log(valueIndex)
      let tempList = [];
      tempList = deepClone(this.paramsBackList);
      this.paramsCommentList[index] = tempList[index];
      this.paramsCommentList[index].value = valueItem;
    },
    dialogClose() {
      this.itemExportData = {
        dateBetween: [],
      };
      this.exportDialogFlag = false;
    },
    tableSearch() {
      let param = {};
      for (let key in this.searchData) {
        if (key === "dateBetween") {
          param.dateStart =
            this.searchData[key] && this.searchData[key].length > 0
              ? this.searchData[key][0] + " 00:00:00"
              : "";
          param.dateEnd =
            this.searchData[key] && this.searchData[key].length > 0
              ? this.searchData[key][1] + " 23:59:59"
              : "";
        } else {
          param[key] = this.searchData[key];
        }
      }
      this.searchDataForTable = param;
      this.$nextTick(() => {
        this.$refs.modelCalibrationTable.formDataInit(true);
      });
    },

    getBeforeDate(n) {
      const d = new Date();
      let mon = d.getMonth() + 1;
      const day = d.getDate();
      if (day <= n) {
        if (mon > 1) {
          mon = mon - 1;
        } else {
          mon = 12;
        }
      }
      d.setDate(d.getDate() - n);
      return d;
    },
    getEquipment() {
      this.$fetch({
        url: process.env.PROGOO_GATE_WATER + "admin/algorithm/equipmentList",
        method: "get",
        data: {},
      }).then((res) => {
        if (res.data.code === 200) {
          this.equipmentList = res.data.result;
          this.optimizeForm.equipment = this.equipmentList[0].id;
        } else {
          this.$notify.error({
            title: "错误",
            message: res.data.message,
          });
        }
      });
    },
    getParams() {
      this.$fetch({
        url: process.env.PROGOO_GATE_WATER + "admin/paramThreshold",
        method: "post",
        data: {
          page: 1,
          limit: 999,
        },
      }).then((res) => {
        if (res.data.code === 200) {
          this.paramsList = res.data.result.content;
          this.paramsList.reverse();
          for (let i in this.paramsList) {
            this.dataDisplayItem.push(this.paramsList[i]);
          }
          for (let j = 1; j < this.dataDisplayItem.length; j++) {
            this.dataDisplayItem[j].label = this.dataDisplayItem[j].paramname;
            this.dataDisplayItem[j].prop = this.dataDisplayItem[j].paramkey;
          }
          for (let i in this.modelDisplayItem) {
            if (this.modelDisplayItem[i].prop === "paramKey") {
              this.modelDisplayItem[i].enums = [];
              for (let l in this.paramsList) {
                let item = this.paramsList[l];
                item.value = this.paramsList[l].paramkey;
                item.text = this.paramsList[l].paramname;
                this.modelDisplayItem[i].enums.push(item);
              }
            }
          }
        } else {
          this.$notify.error({
            title: "错误",
            message: res.data.message,
          });
        }
      });
    },
    commentDialogOpen() {
      this.chartXais_show = []
      this.getAllCharts(0);
    },
    getCharts(item) {
      //第一个曲线图
      let echarts = require("echarts");
      let dom = document.getElementById("myechart");
      this.chartXais = item.time;
        //时间格式化
      this.timeFormatAll();
      let svalue = item.svalue.reverse();
      let tvalue = item.tvalue.reverse();
      let chooseValue = item.pvalue.reverse();
      if (
        dom.getAttribute("_echarts_instance_") &&
        dom.getAttribute("_echarts_instance_") !== ""
      ) {
        dom.removeAttribute("_echarts_instance_");
        dom.innerHTML = "";
      }
      let myChart = echarts.init(dom);
      let option = {
        title: {},
        tooltip: {
          trigger: "axis",
        },
        legend: {
          data: ["模型-均值", "输入-均值",'已选-均值'],
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: this.chartXais_show,
          axisLabel: {
            rotate: 30,
          },
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            name: "模型-均值",
            type: "line",
            data: svalue,
            smooth: true,
          },
          {
            name: "输入-均值",
            type: "line",
            data: tvalue,
            smooth: true,
          },{
            name: "选择-均值",
            type: "line",
            data: chooseValue,
            smooth: true,
          },
        ],
      };
      myChart.setOption(option);
    },
    getAllCharts(key) {
      //第一个曲线图
      let echarts = require("echarts");
        let dom = document.getElementById("echart" + key);
        this.chartXais = this.paramsBackList[key].time.reverse();
        //时间格式化
        this.timeFormatAll();
        let svalue = this.paramsBackList[key].svalue.reverse();
        let tvalue = this.paramsBackList[key].tvalue.reverse();
        let diffValue = this.paramsBackList[key].value[0].pvalue.reverse();
        let ratioValue = this.paramsBackList[key].value[1].pvalue.reverse();
        let fitValue = this.paramsBackList[key].value[2].pvalue.reverse();
        if (
          dom.getAttribute("_echarts_instance_") &&
          dom.getAttribute("_echarts_instance_") !== ""
        ) {
          dom.removeAttribute("_echarts_instance_");
          dom.innerHTML = "";
        }
        let myChart = echarts.init(dom);
        let option = {
          title: {},
          tooltip: {
            trigger: "axis",
          },
          legend: {
            data: ["模型-均值","输入-均值", "均差-结果","均比-结果","拟合-结果"],
          },
          grid: {
            left: "10%",
            right: "4%",
            bottom: "3%",
            containLabel: true,
          },
          toolbox: {
            feature: {
              saveAsImage: {},
            },
          },
          xAxis: {
            type: "category",
            boundaryGap: false,
            data: this.chartXais_show,
            axisLabel: {
              rotate: 20,
            },
          },
          yAxis: {
            type: "value",
          },
          series: [
            {
              name: "模型-均值",
              type: "line",
              data: svalue,
              smooth: true,
            },
            {
              name: "输入-均值",
              type: "line",
              data: tvalue,
              smooth: true,
            },
            {
              name: "均差-结果",
              type: "line",
              data: diffValue,
              smooth: true,
            },
            {
              name: "均比-结果",
              type: "line",
              data: ratioValue,
              smooth: true,
            },
            {
              name: "拟合-结果",
              type: "line",
              data: fitValue,
              smooth: true,
            },
          ],
        };
        myChart.setOption(option);
      
    },
    sendDataTo() {
      if (this.paramsCommentList.length === this.paramsBackList.length) {
        this.modelCommentList.modelText = deepClone(this.paramsCommentList);
        this.$fetch({
          url: process.env.PROGOO_GATE_WATER + "model/saveCalibrationModel",
          method: "post",
          data: this.modelCommentList,
        }).then((res) => {
          if (res.data.code === 200) {
            this.$notify({
              title: "模型选择成功！",
              message: "请在页面查看模型",
              type: "success",
            });
            this.commentDialogFlag = false;
            this.$nextTick(() => {
              this.$refs.modelCalibrationTable.formDataInit(true);
            });
          } else {
            this.$notify.warning({
              title: "警告",
              message: "请选择参数模型！",
            });
          }
        });
      } else {
        //默认选每个模型的第一个
        this.paramsCommentList = deepClone(this.paramsBackList);
        for (let i in this.paramsBackList) {
          this.paramsCommentList[i].value = this.paramsBackList[i].value[0];
        }

        // this.$notify.warning({
        //   title: "警告",
        //   message: "请选择完整参数模型！",
        // });
      }
    },
    timeFormatAll() {
      for(let i in this.chartXais){
        this.chartXais_show[i] = utils.formatDate('MM-dd hh:mm:ss', new Date(parseInt(this.chartXais[i])))
      }
    },
    cancelData() {
      this.commentDialogFlag = false;
    },
    timeFormat(e) {
      for (let i in e) {
        e[i] =
          e[i].slice(0, 4) +
          "-" +
          e[i].slice(4, 6) +
          "-" +
          e[i].slice(6, 8) +
          " " +
          e[i].slice(8, 10) +
          ":" +
          e[i].slice(10, 12) +
          ":" +
          e[i].slice(12, 14);
      }
    },
    clearInput(){
      this.optimizeForm =  {
        equipmentId: "",
        paramKeyList: [],
        dateBetween: "",
        selectId: [],
        type: "",
        username: localStorage.getItem("username"),
        remark: "",
      };
      this.dataEntryTableData = {};
      this.selectList = [];
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less">
.modelCalibration {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 15px;
  overflow-y: scroll;
  .modelCalibration_table {
    width: 100%;
    overflow-y: auto;
  }
  .modelOptimization_searchFrom {
    width: 100%;
  }
  .modelOptimization_searchFromItem {
    float: left;
  }
  .commentContent {
    display: flex;
    flex-direction: column;
    .commentContentTop{
      display: flex;
      flex-direction: row;
      .commentContentTopItem{
        width: 180px;
        margin:  0 20px;
        line-height: 50px;
        font-size: 16px;
      }
    }
    .commentContentMiddle{
      display: flex;
      flex-direction: column;
      border: 1px solid #b2b2b2;
      padding: 10px 20px;
      .commentContentItem {
        margin: 5px 20px ;
        .el-radio,
        .el-radio__input {
          white-space: normal !important;
          line-height: 30px !important;
          .everyComment {
          }
        }
      }

    }
  }
  .evaluateShowTitle {
    margin: 10px 6% ;
    font-size: 16px;
    width: 88%;
  }
  .evaluateShow {
    margin: 10px 6% 20px 6%;
    width: 88%;
    height: 100%;
    font-size: 14px;
  }
}
</style>
